package com.excel;

import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
import org.apache.poi.ss.usermodel.Sheet;

/**
 * @author xiang
 * @create 2021/7/8 10:06
 */
public class ExcelHandler implements SheetWriteHandler {
    SheetFunction dealFunction;
    public ExcelHandler(SheetFunction dealFunction){
        super();
        this.dealFunction = dealFunction;
    }

    @Override
    public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {

    }

    @Override
    public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
        Sheet sheet = writeSheetHolder.getSheet();
        sheet.setDefaultColumnWidth(14);
//        sheet.setDefaultRowHeight((short) 5);
        dealFunction.deal(sheet);
    }

}
